<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
        <!-- 开发环境版本，包含了有帮助的命令行警告 -->
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <!-- 模板内容 -->
    <div id="demo">
        <span v-if="loginType=='username'">
            <label>Username</label>
            <input type="text" placeholder="Enter your username" key="username-input">
        </span>
        <span v-else="expression" >
            <label>Email</label>
            <input type="text" placeholder="Enter your email address" key="email-input">
        </span>
        <button v-on:click="test">切换</button>
    </div>
    <!-- js -->
    <script>
        var demo = new Vue({
            el:"#demo",
            data:{
              loginType:"username"
              
            },
            methods: {
                test:function(){
                  if(this.loginType!='username'){
                     return this.loginType='username'
                  }
                  return this.loginType='email'
              }
            }
        })
    </script>
</body>
</html>
